<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="viewport"
	content="width=device-width,height=device-height, initial-scale=1.0, user-scalable=no">
    <script type="text/javascript" src="${s.base}/res/mobile/js/zepto.min.js"></script>
		
	<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js "></script>
    <script type="text/javascript" src="${s.base}/res/js/global.js"></script> 


<title>二维码登陆验证</title>
<style>
* {
	padding: 0px;
	margin: 0px;
}
html {
	background: rgba(0, 81, 151, 1);	/*	background: rgba(21, 72, 153, 1);  rgba(2, 82, 84, 1)*/
	color:white;
}
body {
	 
}

#codeArea {
	width: 100%;
	height: 100%;
	margin: 100px auto;
}

#codeImg {
 	
	border-radius: 2px;
}

#title {
	width: 100%;
	line-height: 30px;
	text-align: center;
}

#content {
	padding: 30px;
	color: white;
	text-align: center;
}

#content p {
	margin: 3px;
}

.codeBorder {
	width: 66px;
	height: 66px;
	margin: 0 auto;
	border-radius: 5px;
	border: 1px solid rgba(247, 247, 247, 0.36);
	padding: 4px;
	box-shadow: 1px 2px 2px #222;
}

.codeBorder img {
	border-radius: 68px;
	-moz-border-radius: 68px;
	-webkit-border-radius: 68px;
}

.button {
	width: 200px;
	height: 30px;
	margin: 20px auto;
	background: linear-gradient(to bottom, rgba(122, 255, 144, 0.91),
		rgba(55, 171, 75, 0.8), rgba(74, 193, 94, 0.5));
	border: 1px solid #928888;
	box-shadow: 1px 2px 2px #222;
	border-radius: 5px;
	line-height: 30px;
	cursor: pointer;
}

.line {
	width: 100%;
	height: 0px;
	border-top: 1px solid #FFF;
	border-bottom: 1px solid #0A0A0A;
	box-shadow: 0px 1px 0px #9A9999;
	margin-top: 10px;
}

.copy, .name {
	height: 30px;
	width: 100%;
	line-height: 30px;
}

.name {
	
}
</style>

</head>
<body>
	<div id="codeArea">

		<div class="codeBorder">
			<img id="codeImg" alt="登陆二维码" width=64 height=64 src="${s.base}/res/images/corpimg/${cfg.corpicon}">

		</div>
		<div id="content">
			<div class="name">${cfg.provincename}</div>
			<div class="copy">重庆东电科技有限公司</div>
			<div class="line"></div>
			<div class="button" id="confirm">确认登录</div>

		</div>

	</div>
	
</body>

	<script type="text/javascript">
	
	
	   CONETXT_PATH = '${s.base}';
   	   var CONETXT_USERID='${userid}';
   	   var CONETXT_PROVINCE='${province}';
   	   
   	   
		 $(function(){
	
		 
		  $("#confirm").on("click",function(){
	 
       
			  sendJSON({type:"login",state:"${state}",userid:CONETXT_USERID,province:CONETXT_PROVINCE, result:"confirmOk",message:"授权成功，正在跳转！" });
           	 
		
			   
		  });
			  
		
		  
		 });
		  
		    
		   //判断当前浏览器是否支持WebSocket
		    if ('WebSocket' in window) {
		        websocket = new WebSocket("ws://"+ window.location.host+CONETXT_PATH+"/websocket");
		    }
		    else {
		        alert('暂不支持该浏览器，请使用高版本浏览器')
		    }

		    //连接发生错误的回调方法
		    websocket.onerror = function () {
		      //  setMessageInnerHTML("WebSocket连接发生错误");
		    };

		    //连接成功建立的回调方法
		    websocket.onopen = function () {
		       // setMessageInnerHTML("WebSocket连接成功");
		         var msg={type:"login",state:"${state}",userid:CONETXT_USERID,province:CONETXT_PROVINCE,result:"codeOk",message:"扫描成功！" };
		         sendJSON(msg);
		    	  
		    }

		    //接收到消息的回调方法
		    websocket.onmessage = function (event) {
		      //  setMessageInnerHTML(event.data);
		    }

		    //连接关闭的回调方法
		    websocket.onclose = function () {
		      //  setMessageInnerHTML("WebSocket连接关闭");
		    }

		    //监听窗口关闭事件，当窗口关闭时，主动去关闭websocket连接，防止连接还没断开就关闭窗口，server端会抛异常。
		    window.onbeforeunload = function () {
		        closeWebSocket();
		    }

		    //将消息显示在网页上
		    function setMessageInnerHTML(innerHTML) {
		       // document.getElementById('message').innerHTML += innerHTML + '<br/>';
		    }

		    //关闭WebSocket连接
		    function closeWebSocket() {
		        websocket.close();
		    }
		    function sendJSON(msg){
		    	websocket.send(JSON.stringify(msg));
		    }

		    //发送消息
		    function send() {
		        var message = document.getElementById('text').value;
		        websocket.send(message);
		    }
		  
 </script>
</html>